﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Triunfadores.BusinessEntities;

namespace Triunfadores.Repository.Mapping
{
    public class VentaAccionMap:EntityTypeConfiguration<VentaAccion>
    {
        public VentaAccionMap()
        {
            //Primary key y que sea auto-incrementable
            this.HasKey(va => va.Id);
            this.Property(va => va.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            //propiedades
            this.Property(va => va.FechaVenta)
                .HasColumnType("datetime2")
                .IsRequired();
            this.Property(va => va.Total)
                .HasColumnType("decimal")
                .HasPrecision(9, 2)
                .IsRequired();
            this.Property(va => va.Estado)
                .HasColumnType("varchar")
                .HasMaxLength(10)
                .IsRequired();

            //relaciones
            this.HasRequired(va => va.Socio)
                .WithMany(va => va.IcVentaAcciones)
                .HasForeignKey(va => va.IdSocio)
                .WillCascadeOnDelete(false);

        }
    }
}
